#pragma once

#include "Widgets/Widget.h"
#include "Event/KeyboardEvent.h"
#include "Event/TextInputEvent.h"
#include "KeyboardWidget.m.h"

//keyboard widget
//will auto unfocus when mouse is out of it
RCLASS()
class WHENGINE_API RKeyboardWidget : public RWidget
{
    ROBJECT
public:
    RKeyboardWidget();

    //invoked when get focused
    TDelegate<void> OnKeyboardFocused;  
    //invoked when lost focused
    TDelegate<void> OnKeyboardUnfocused;

    TDelegate<bool,const SKeyboardEvent&> OnKeyboardInput;
    TDelegate<bool,const STextInputEvent&> OnTextInput;

    bool IsFocused() const;

    void ToggleFocus();
    void Focus();
    void Unfocus();
protected:
    friend class CWidgetTree;

    bool ProcessKeyboardEvent(const SKeyboardEvent& keyBoardEvent);
    bool ProcessTextInput(const STextInputEvent& InTextInputEvent);


    void OnFocused();

    void OnUnfocused();

};